package cn.mafangui.hotel.enums;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.boot.jackson.JsonObjectDeserializer;

import java.util.List;

@Getter
@AllArgsConstructor
public enum RoomStatus {

    UNAVAILABLE(0,"不可用"),
    AVAILABLE(1,"空闲"),
    ORDERED(2,"被预订"),
    IN_USE(3,"已入住"),
    ;
    private int code;
    private String status;


    /**
     * 得到房间所有的枚举值和枚举代码
     * @return
     */
    public static JSONArray getAllStatus(){
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject;
        for(RoomStatus roomStatus : RoomStatus.values()){
            jsonObject = new JSONObject();
            jsonObject.put("code", roomStatus.getCode());
            jsonObject.put("msg", roomStatus.getStatus());
            jsonArray.add(jsonObject);
        }
        return jsonArray;
    }

}
